<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<%@include file="../include/contentheader.jsp"%>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
	<link rel="StyleSheet" type="text/css" href="css/dtree.css"/>
	<script type="text/javascript" src="js/dtree.js"></script>
	
	<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/departmentDwrJs.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>
	<script type="text/javascript" src="js/dep.js"></script>
	<link rel="StyleSheet" href="css/dep.css" type="text/css" />
</head>

<body>
	<div class="mainContainer">
   	<div class="headerTitle">基础信息管理&nbsp;>>&nbsp;盘点管理</div>
       	<div class="dtreeDiv" id="deptree" style="display: block;">
       		<div>
       			<input type="button" value="显示类别树" onclick="showSortTree();" style="width: 40%;margin-left: 30%;margin-right: 30%;"/>
       		</div>
       		<div id="myTree">
       		<script type="text/javascript">
       		var myTree1=document.getElementById("myTree");
   			d1 = new dTree('d1');
   			var inner1;
   			buildTree1();
   			function buildTree1(){
   				departmentDwrJs.getAllDepartment(function(departmentList) {
   				d1.add(0, -1, '广元电业局');
    			for(var i=0; i<departmentList.length; i++){
        			for(var j=0; j<departmentList.length; j++){
            			if(departmentList[i].depid==departmentList[j].depparentid){
        					d1.add(departmentList[j].depid,departmentList[j].depparentid,departmentList[j].depname,"queryAssetInDepartmentTree.action?FN=<s:property value='FN' />&depname="+departmentList[j].depname);
        				}
            		}
    			}
    			inner1 = d1.toString();
    			showBuildTree1();
    			});
    		}
			function showBuildTree1(){
				myTree1.innerHTML = inner1;
	  	 	}
			</script>
			</div>
        </div>
        <div class="dtreeDiv" id="sorttree" style="display: none;">
        	<div>
        		<input type="button" value="显示部门树" onclick="showDepTree();" style="width: 40%;margin-left: 30%;margin-right: 30%;"/>
        	</div>
        	<div id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0, -1, '广元电业局');
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var url = "queryAssetInCategoryTree.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
			</script>
			</div>
		</div>
        <div class="dataDivLeftHasTree">
        	<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
				<tr class="operatorAction">
					<td>
					<!-- 功能性操作 -->
					<input type="button" style="margin-left:2px;" value="刷新" onclick="refurbish()"/>
					<input type="button" style="margin-left:2px;width: 80px;" value="盘盈资产录入" onclick="surplusInput()"/>
					<input type="button" style="margin-left:2px;width: 80px;" value="盘盈入库申请" onclick="surplusDeclare()"/>
					<input type="button" style="margin-left:2px;" value="盘亏申报" onclick="loseDeclare()"/>
					<input type="button" style="margin-left:2px;width: 90px;" value="盘亏财务部审核" onclick="loseDeclaration()"/>
					<input type="button" style="margin-left:2px;width: 90px;" value="盘亏财务部退回" onclick="loseDeclarationUntread()"/>
					<input type="button" style="margin-left:2px;width: 90px;" value="盘亏财务部上报" onclick="loseReport()"/>
					<input type="button" style="margin-left:2px;" value="盘亏确认" onclick="loseValidate()"/>
					<input type="button" style="margin-left:2px;" value="盘亏退回" onclick="loseValidateUntread()"/>
					<input type="button" style="margin-left:2px;" value="导出" onclick="exportTable()"/>
					
					查询条件：根据&nbsp;&nbsp;<select style="width: 94px;" id="condition" onblur="acstatusValueBeChosen()">
	  					<option value="acname" selected="selected">资产名称</option>
						<option value="acstatus">资产状态</option>
	  				</select>
	  				
	  				<input style="margin-left:10px;" type="text" id="conditionValue"/>
	  				
	  				<select style="display: none;width: 150px;" class="qryTxt" id="acstatusValue">
	  					<option value="400" selected="selected">在用</option>
						<option value="901">盘点-盘盈数据已录入</option>
						<option value="902">盘点-盘盈入库已申报</option>
						<option value="903">盘点-盘亏已申报</option>
						<option value="904">盘点-盘亏财务部已审核</option>
						<option value="905">盘点-盘亏财务部已上报</option>
						<option value="906">盘点-盘亏确认</option>
	  				</select>
	  				
	  				<input type="button" style="margin-left:1px;" value="查询" onclick="selectAssetCartByCondition()"/>
					</td>
				</tr>
				
				<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
						  	<td width="2%"><input id="checkAll" type="checkbox" /></td>
						  	<td width="5%">资产卡片编号</td>
							<td width="5%">名称</td>
							<td width="3%">所在部门</td>
							<td width="3%">是否公用</td>
							<td width="5%">状态</td>
							<!-- <td width="5%">使用人</td> -->
							
							<td width="5%">操作人</td>
							<td width="5%">操作角色</td>
							<td width="6%">状态</td>
							<td width="5%">处理结果</td>
							<td width="7%">处理意见</td>
							<td width="5%">处理时间</td>
							<td width="5%">原使用人</td>
							<td width="5%">现使用人</td>
							
							<td width="3%">类别</td>
							<td width="5%">生产日期</td>
							<td width="5%">使用期限</td>
							<td width="5%">预计停用日期</td>
							<td width="5%">采购价格</td>
							<td width="3%">计量单位</td>
							<td width="3%">规格</td>
							<td width="5%">生产厂家</td>
						</tr>
						
						<s:iterator var="ac" value="pagination.dataList" status="sta"> 
						<tr class="dataRow" id="<s:property value='#ac.acid'/>">
							<td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid' />" /></td>

							<td><s:property value="#ac.acid" /></td>
							<td><s:property value="#ac.acname" /></td>
							<td><s:property value="#ac.depname" /></td>
							<td><s:property value="#ac.ispublic" /></td>
							<td><s:property value="#ac.acstatus" /></td>
							<!-- <td><s:property value="#ac.acuser" /></td> -->
							
							
							<td colspan="8" style="background-color: #ccc;">
								<s:iterator var="bo" value="#ac.book" status="ats">
								
								</s:iterator>
							</td>
							
							
							<!-- <td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td>
							<td><s:property value="#ac." /></td> -->
							
							<td><s:property value="#ac.category.catname" /></td>
							<td><s:property value="#ac.producedate" /></td>
							<td><s:property value="#ac.lifetime" /></td>
							<td><s:property value="#ac.planstopdate" /></td>
							<td><s:property value="#ac.orderprice" /></td>
							<td><s:property value="#ac.category.catunit" /></td>
							<td><s:property value="#ac.category.catnorms" /></td>
							<td><s:property value="#ac.producer" /></td>
						</tr>
						</s:iterator>
					</table>
				</td>
			</tr>
			<tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>
			</table>
        </div>
	</div>
	
	<script type="text/javascript">
		//显示部门树
		function showDepTree(){
			var deptree=document.getElementById("deptree");
			var sorttree=document.getElementById("sorttree");	
			sorttree.style.display="none";	
			deptree.style.display="inline";
		}
		//显示类别树
		function showSortTree(){
			var deptree=document.getElementById("deptree");
			var sorttree=document.getElementById("sorttree");	
			deptree.style.display="none";	
			sorttree.style.display="inline";
		}
		//刷新
		function refurbish(){
			location.href="searchCheckAsset.action?FN=<s:property value='FN' />";
		}
		//盘盈资产录入
		function surplusInput(){
			location.href="page/daily/searchAllDepartment.action?FN=<s:property value='FN' />";
		}
		//盘盈入库申报
		function surplusDeclare(){
			var allWhAssetCard = $("input:checked");
			var str="";
			if(allWhAssetCard.length == 0){
				alert("请选择");
			}else{
				for(var i=0;i<allWhAssetCard.length;i++){
					str=str+allWhAssetCard[i].value+",";
				}
				alert(str);
				location.href = "page/daily/inputWarehouseSurplus.action?FN=<s:property value='FN' />&acidAll="+str;
			}
		}
		//盘亏申报
		function loseDeclare(){
			var allWhAssetCard = $("input:checked");
			var str="";
			if(allWhAssetCard.length == 0){
				alert("请选择");
			}else{
				for(var i=0;i<allWhAssetCard.length;i++){
					str=str+allWhAssetCard[i].value+",";
				}
				alert(str);
				location.href = "declareLost.action?FN=<s:property value='FN' />&acidAll="+str;
			}
		}
		//盘亏财务部审核
		function loseDeclaration(){
			//需要弹出对话框要求输入审核通过的原因
			var allWhAssetCard = $("input:checked");
		    if(allWhAssetCard.length == 0){
	    		alert("请选择");
		    }else if(allWhAssetCard.length == 1){
		    	var vRValue=showdepartment();
		    	if(vRValue == undefined){
					ideaValue="操作人按了取消键";
					alert("输入为未定义-->"+ideaValue);
				}else if(vRValue==''){
					ideaValue="操作人没有输入审批意见";
					alert("输入为空字符串-->"+ideaValue);
					location.href = "declarationLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=同意";
				}else{
					alert("输入了-页面-->"+vRValue);
					location.href = "declarationLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
				}
		    }else{
		    	alert("每次只能审核操作一个资产");
			}
		}
		//盘亏财务部退回
		function loseDeclarationUntread(){
			//需要弹出对话框要求输入退回的原因
			var allWhAssetCard = $("input:checked");
		    if(allWhAssetCard.length == 0){
	    		alert("请选择");
		    }else if(allWhAssetCard.length == 1){
		    	var vRValue=showdepartment();
		    	if(vRValue == undefined){
					ideaValue="操作人按了取消键";
					alert("输入为未定义-->"+ideaValue);
				}else if(vRValue==''){
					ideaValue="操作人没有输入退回意见";
					alert("输入为空字符串-->"+ideaValue);
					location.href = "declarationUntreadLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=退回";
				}else{
					alert("输入了-页面-->"+vRValue);
					location.href = "declarationUntreadLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
				}
		    }else{
		    	alert("每次只能退回操作一个资产");
			}	
		}
		//盘亏财务部上报
		function loseReport(){
			var allWhAssetCard = $("input:checked");
			var str="";
			if(allWhAssetCard.length == 0){
				alert("请选择");
			}else{
				for(var i=0;i<allWhAssetCard.length;i++){
					str=str+allWhAssetCard[i].value+",";
				}
				alert(str);
				location.href = "reportLost.action?FN=<s:property value='FN' />&acidAll="+str;
			}
		}
		//盘亏确认
		function loseValidate(){
			//需要弹出对话框要求输入确认通过的原因
			var allWhAssetCard = $("input:checked");
		    if(allWhAssetCard.length == 0){
	    		alert("请选择");
		    }else if(allWhAssetCard.length == 1){
		    	alert("确认的资产编号-->"+allWhAssetCard[0].value);

		    	var vRValue=showdepartment();
		    	if(vRValue == undefined){
					ideaValue="操作人按了取消键";
					alert("输入为未定义-->"+ideaValue);
				}else if(vRValue==''){
					ideaValue="操作人没有输入盘亏确认意见";
					alert("输入为空字符串-->"+ideaValue);
					location.href = "validateLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=同意";
				}else{
					alert("输入了-页面-->"+vRValue);
					location.href = "validateLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
				}
		    }else{
		    	alert("每次只能确认操作一个资产");
			}
		}
		//盘亏退回
		function loseValidateUntread(){
			//需要弹出对话框要求输入退回通过的原因
			var allWhAssetCard = $("input:checked");
		    if(allWhAssetCard.length == 0){
	    		alert("请选择");
		    }else if(allWhAssetCard.length == 1){
		    	alert("退回的资产编号-->"+allWhAssetCard[0].value);

		    	var vRValue=showdepartment();
		    	if(vRValue == undefined){
					ideaValue="操作人按了取消键";
					alert("输入为未定义-->"+ideaValue);
				}else if(vRValue==''){
					ideaValue="操作人没有输入盘亏退回意见";
					alert("输入为空字符串-->"+ideaValue);
					location.href = "validateUntreadLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue=退回";
				}else{
					alert("输入了-页面-->"+vRValue);
					location.href = "validateUntreadLost.action?FN=<s:property value='FN' />&acid="+allWhAssetCard[0].value+"&ideaValue="+vRValue;
				}
		    }else{
		    	alert("每次只能确认操作一个资产");
			}
		}
		//导出
		function exportTable(){
			showExportTree();
		}
		//显示导出条件选择页面
		function showExportTree(){
			window.showModalDialog("page/daily/exportTree.jsp",null,"dialogWidth=320px;dialogHeight=450px;status=0;scroll=0");
		}
		//条件查询
		function selectAssetCartByCondition(){
			var property=document.getElementById("condition");
			var propertyValue=property.options[property.selectedIndex].value;
			if(propertyValue=="acstatus"){
				var propertyBeChoose=document.getElementById("acstatusValue");
				var propertyValueBeChoose=propertyBeChoose.options[propertyBeChoose.selectedIndex].value;

				alert("条件查询：propertyValueBeChoose条件值-->"+propertyValueBeChoose+",chusValue条件属性-->"+propertyValue);

				location.href = "getCheckAssetCardByPageNumberAndValue.action?FN=<s:property value='FN' />&propertyValue="+propertyValue+"&propertyValueBeChoose="+propertyValueBeChoose;
			}else{
				var inputValue=document.getElementById("conditionValue").value;

				alert("条件查询：inputValue条件值-->"+inputValue+",chusValue条件属性-->"+propertyValue);

				location.href = "getCheckAssetCardByPageNumberAndValue.action?FN=<s:property value='FN' />&propertyValue="+propertyValue+"&inputValue="+inputValue;
			}
		}
		//显示意见输入页面
		function showdepartment(){
			var vRValue = window.showModalDialog("page/daily/idea.jsp",null,"dialogWidth=320px;dialogHeight=450px;status=0;scroll=0");
			return vRValue;
		}
		//条件选择
		function acstatusValueBeChosen(){
			var property=document.getElementById("condition");
			var conditionValue=document.getElementById("conditionValue");
			var acstatusValue=document.getElementById("acstatusValue");
			if(property.options[property.selectedIndex].value=="acstatus"){
				conditionValue.style.display="none";	
				acstatusValue.style.display="inline";
			}else{
				conditionValue.style.display="inline";	
				acstatusValue.style.display="none";
			}
		}
	</script>
</body>
</html>